{ Statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=2786
  Verdict: Accepted
}
uses
	SysUtils, Math; 
 
type
	al = array[1..3] of longint;
 
var
	i, n, m, k, kk : longint;
	r, p : array[0..50010] of longint;
	a : array[0..150010, 1..3] of longint;
	b : array[0..150010] of boolean;
	s : string;
	ch : char;
 
procedure makeSet(v:longint);
begin
p[v] := v;
r[v] := 0;
end;
 
function findSet(v:longint):longint;
begin
if v = p[v] then begin
	result := v;
	exit;
end;
p[v] := findSet(p[v]);
result := p[v];
end;
 
procedure unionSets(a,b:longint);
 
var
	t:longint;
 
begin
a := findSet(a);
b := findSet(b);
if a <> b then begin
	if r[a] < r[b] then begin
		t := a;
		a := b;
		b := t;
	end;
	p[b] := a;
	if r[a] = r[b] then inc(r[a]);
end;
end;
 
begin
	reset(input,'input.txt');
	rewrite(output,'output.txt');
	readln(n, m, k);
	for i := 1 to n do
		makeSet(i);
	for i := 1 to m do 
		readln(s);
	for i := 1 to k do begin
		readln(S);
		ch := s[1];
		delete(s, 1, pos(' ', s));
		kk := pos(' ', s);
		a[i][2] := strtoint(copy(s, 1, kk - 1));
		delete(s, 1, kk);
		a[i][3] := strtoint(s);
		if ch = 'c' then a[i][1] := 1 else a[i][1] := 2;
	end;
	kk := 0;
	for i := k downto 1 do
		if a[i][1] = 1 then unionSets(a[i][2], a[i][3]) else begin
			inc(kk);
			b[kk] := findSet(a[i][2]) = findSet(a[i][3]);
		end;
	for i := kk downto 1 do
		if b[i] then writeln('YES') else writeln('NO');
end.